<template>
  <div class="title">
    <div class="title-con">
      <div v-if="!goBack" class="back-block"></div>
      <div v-if="backToPage!==''" class="back" @click="backTo"></div>
      <div v-if="goBack && backToPage===''" class="back" @click="back"></div>
      <div class="txt">{{title}}</div>
      <div class="icon"></div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      default: ''
    },
    goBack: {
      type: Boolean,
      default: true
    },
    backToPage: {
      type: String,
      default: '',
    }
  },
  methods: {
    back(){
      this.$router.back()
    },
    backTo(){
      this.$router.push(this.backToPage)
    }
  },
}
</script>

<style scoped>
.title{
  height: 50px;
  overflow: hidden;
}
.title-con{
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  line-height: 50px;
  color: #ffffff;
  text-align: center;
  background-color: #000000;
  z-index: 1001;
}
.title-con .back-block{
  position: relative;
  width: 50px;
  height: 50px;
}
.title-con .back{
  position: relative;
  width: 50px;
  height: 50px;
}
.title-con .back:after{
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  top: 18px;
  border-bottom: 2px solid #ffffff;
  border-left: 2px solid #ffffff;
  transform: rotate(45deg);
}
.title-con .txt{
  flex-grow: 1;
  font-size: 16px;
}
.title-con .icon{
  width: 50px;
  height: 50px;
}
</style>